package com.gml.design.principle.lishitihuan.optimize;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * 银行卡
 */
public abstract class BankCard {
    private Logger logger = LoggerFactory.getLogger(BankCard.class);

    private String cardNo;//卡号

    private String cardDate;//开卡时间

    BankCard(String cardNo, String cardDate){
        this.cardNo = cardNo;
        this.cardDate = cardDate;
    }

    //扣款规则
    abstract boolean rule(BigDecimal amount);

    //正向入账， 存钱
    public String positive(String orderId, BigDecimal amount){
        //入账成功
        logger.info("卡号：{} 入账成功，单号：{} 金额：{}", cardNo, orderId, amount);
        return "0000";
    }

    //逆向入账，付钱
    public String negative(String orderId, BigDecimal amount){
        //扣钱
        logger.info("卡号{}， 出款成功， 单号：{} 金额：{}", cardNo, orderId, amount);
        return "0000";
    }

    /**
     * 交易流水查询
     *
     * @return 交易流水
     */
    public List<String> tradeFlow() {
        logger.info("交易流水查询成功");
        List<String> tradeList = new ArrayList<String>();
        tradeList.add("100001,100.00");
        tradeList.add("100001,80.00");
        tradeList.add("100001,76.50");
        tradeList.add("100001,126.00");
        return tradeList;
    }

    public String getCardNo() {
        return cardNo;
    }

    public String getCardDate() {
        return cardDate;
    }
}
